package com.bw.module_service.view

import androidx.recyclerview.widget.GridLayoutManager
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.bw.lib_base.path.RouterPath
import com.bw.lib_common.entity.MenuEntity
import com.bw.lib_common.view.BaseMvvmFragment
import com.bw.module_service.R
import com.bw.module_service.adapter.ServiceMenuAdapter
import com.bw.module_service.databinding.FragmentServiceBinding

@Route(path = RouterPath.MODULE_SERVICE_FRAGMENT)
class ServiceFragment : BaseMvvmFragment<FragmentServiceBinding>()  {

    private val list = mutableListOf<MenuEntity>().apply {
        add(MenuEntity(R.drawable.service_menu_image1, "车辆管理"))          // 汽车图标
        add(MenuEntity(R.drawable.service_menu_image2, "车位管理"))     // 地锁图标
        add(MenuEntity(R.drawable.service_menu_image3, "访客管理"))    // 证件图标
        add(MenuEntity(R.drawable.service_menu_image4, "维修管理"))      // 图表图标
        add(MenuEntity(R.drawable.service_menu_image5, "公告管理"))      // 电脑图标
        add(MenuEntity(R.drawable.service_menu_image6, "考勤管理"))  // 闹钟图标
        add(MenuEntity(R.drawable.service_menu_image7, "即时通讯"))      // 对话气泡图标
        add(MenuEntity(R.drawable.service_menu_image8, "设备管理"))      // 电脑图标
        add(MenuEntity(R.drawable.service_menu_image9, "房源信息"))           // 房屋图标
        add(MenuEntity(R.drawable.service_menu_image10, "物业报修"))        // 房屋图标
        add(MenuEntity(R.drawable.service_menu_image11, "巡检管理"))  // 放大镜图标
        add(MenuEntity(R.drawable.service_menu_image12, "月卡会员"))        // 卡片图标
        add(MenuEntity(R.drawable.service_menu_image13, "收银台"))        // 卡片图标
    }
    private val serviceMenuAdapter = ServiceMenuAdapter()

    override fun initViews() {
        super.initViews()
        serviceMenuAdapter.data.addAll(list)
        serviceMenuAdapter.notifyDataSetChanged()
        binding.serviceRv.adapter = serviceMenuAdapter
        binding.serviceRv.layoutManager = GridLayoutManager(requireContext(), 3)
        serviceMenuAdapter.setOnItemClickListener { adapter, view, position ->
            // 在这里处理点击事件
            when(position){
                0->{
                    ARouter.getInstance().build(RouterPath.MODULE_CAR_ACTIVITY).navigation()
                }
                1->{
                    ARouter.getInstance().build(RouterPath.MODULE_PARKING_ACTIVITY).navigation()
                }
                2->{
                    ARouter.getInstance().build(RouterPath.MODULE_VISIT_ACTIVITY).navigation()
                }
                3->{
                    ARouter.getInstance().build(RouterPath.MODULE_REPAIR_ACTIVITY).navigation()
                }
                4->{
                    ARouter.getInstance().build(RouterPath.MODULE_NEWS_ACTIVITY).navigation()
                }
                5->{
                    ARouter.getInstance().build(RouterPath.MODULE_SIGN_ACTIVITY).navigation()
                }
                6->{
                    ARouter.getInstance().build(RouterPath.MODULE_COMMUNICATION_ACTIVITY).navigation()
                }
                7->{
                    ARouter.getInstance().build(RouterPath.MODULE_DEVICE_ACTIVITY).navigation()
                }
                8->{
                    ARouter.getInstance().build(RouterPath.MODULE_PROPERTY_ACTIVITY).navigation()
                }
                9->{
                    ARouter.getInstance().build(RouterPath.MODULE_REPAIR_ACTIVITY).navigation()
                }
                10->{
                    ARouter.getInstance().build(RouterPath.MODULE_PATROL_ACTIVITY).navigation()
                }
                11->{
                    ARouter.getInstance().build(RouterPath.MODULE_MEMBER_ACTIVITY).navigation()
                }
                12->{
                    ARouter.getInstance().build(RouterPath.MODULE_CASH_DESK_ACTIVITY).navigation()
                }
            }
        }
    }

    override fun observeDataChange() {
    }

    override fun getLayoutId(): Int =R.layout.fragment_service

}